﻿require("react-hot-loader/patch")
import React, { Component} from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as actions from '../actions/actions';
import $ from 'jquery';
import CsMenu from './common/csMenu.js';
import SideMenu from './common/sideMenu.js';
import TableTest from './views/tableTest.js';
import 'antd/dist/antd.less';
import '../less/style.less';
import { Menu, Icon } from 'antd';
const SubMenu = Menu.SubMenu;
const MenuItemGroup = Menu.ItemGroup;
import {createBrowserHistory,createHashHistory} from 'history'
const history = createHashHistory()

import {
	HashRouter as Router,
	Route,
	Link,
	NavLink,
	withRouter,
	Redirect,
	Switch
} from 'react-router-dom'

class App extends Component {
	constructor(props) {
		super(props);
	}
	componentWillReceiveProps(nextProp){
	}
	componentDidMount(){
		const {dispatch}=this.props;
		dispatch.navRequest()
	}
	render() {
		const{navData}=this.props
		return (
			<div className="ly-appMain">
				<div className="ly-header"></div>
				<Router history={history}>
					<div className="ly-body">
						<div className="ly-sideMenu">
							<CsMenu dataSource={navData} fields={{pId:"pId"}} />
						</div>
						<div className="ly-manView">
							<Route path="/table-test" strict render={({location})=> <TableTest location={location}></TableTest>} />
						</div>
					</div>
				</Router>
			</div>
		)
	}
}

function mapStateToProps(state) {
	return {
		navData: state.nav
	}
}
function mapDispatchToProps(dispatch) {
	return {
		dispatch:bindActionCreators(actions, dispatch)
	}
}
export default connect(
	mapStateToProps,
	mapDispatchToProps
)(App)

